<?php
require_once('../phplib/include.inc.php');

class BackUp extends PageBase{
	public function Ini(){
		PageBase::RequireLogin();
		Util::ValidateRight(1);
		$this->GetBackUp();
	}
	public function GetBackUp(){
		global $CONF;
		$dir = $CONF['backup_path'];
		$files = array();
		$i = 0;
		if (is_dir($dir)) {
		    if ($dh = opendir($dir)) {
		        while (($file = readdir($dh)) !== false) {
		        	if ($file != "." && $file != ".."){
		        		$item = array();
		        		$item['fname'] = $file;
		        		$arr = array();
						ereg("([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})_([0-9]{1,2})_([0-9]{1,2})_([0-9]{1,2})",$file,$arr);
						$time = $arr[1]." ".$arr[2].":".$arr[3].":".$arr[4];
						$item['time'] = $time;
		            	$files[$i++] = $item;
		        	}
		        }
		        closedir($dh);
		    }
		}
		$files = array_reverse($files);
		$this->assign('files',$files);
	}
}
$backup = new BackUp("file:".dirname(__FILE__)."/../home/backup.tpl.html");
$backup->display();
?>